package com.hanyizhu.demostore.controller;

import com.hanyizhu.demostore.entity.Order;
import com.hanyizhu.demostore.service.IOrderService;
import com.hanyizhu.demostore.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author lenovo
 */
@RestController
@RequestMapping("orders")
public class OrderController extends BaseController{

    @Autowired
    private IOrderService iOrderService;
    @RequestMapping("creat")
    public JsonResult<Order> creact(HttpSession session,Integer aid,Integer ... cids){
        Integer uid = getUidFromSession(session);
        String username = getUsernameFromSession(session);
        Order data = iOrderService.create(aid, uid, username, cids);
        return new JsonResult<>(OK,data);
    }
}
